package com.demo.nacos.service;

import com.demo.nacos.config.NacosConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

/**
 * @author ysw
 * @create 2022-07-31-22:41
 * @descreption
 **/
@EnableAsync
@Component
public class ConfigService {

    @Value("${eve.p}")
    private String eve;

    @Async
    @EventListener(ApplicationReadyEvent.class)
    public void handler(){

        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){

                    try {
                        System.out.println(eve);
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
    }
}
